//入口文件数组
//import { pluginConfigFn } from './src/config/plugins.js';
let pluginConfigFn = require('./src/config/plugins.js');
let path = require('path');

const webpack = require('webpack');
let {
	entry,
	plugins
} = pluginConfigFn(__dirname);
module.exports = {
	//入口文件
	entry: entry,
	output: {
		path: __dirname + '/dist',
		filename: "js/[name].bundle.js"
	},
	plugins: [...plugins, new webpack.HotModuleReplacementPlugin()],
	module: {
		rules: [{
				test: /\.m?js$/,
				exclude: /(node_modules|bower_components)/,
				//			exclude:'./node_modules/',//不处理该文件下的东西
				//			include:__dirname+'/src/',
				include: path.resolve(__dirname, 'src'),
				use: {
					loader: 'babel-loader',
					options: {
						presets: ['@babel/preset-env']
					}
				}
			}, {
				test: /\.css$/,
				use: ['style-loader',
					{
						loader: 'css-loader',
						options: {
							importLoaders: 1
						}
					},
					'postcss-loader'
				]
			}, {
				test: /\.less$/,
				use: ['style-loader', 'css-loader', 'postcss-loader', 'less-loader']
			},
			{
				test: /\.scss$/,
				use: ['style-loader', 'css-loader', 'postcss-loader', 'sass-loader']
			}, {
				test: /\.html$/,
				loader: "html-loader"
			}, {
				test: /\.ejs$/,
				loader: "ejs-loader"
			}, {
				test: /\.(png|jpg|gif|svg)$/,
				use: [{
						loader: 'file-loader',
						options: {
							outputPath: 'img/'
						}
					},
					'image-webpack-loader'
				]
			}
		]

	}
}